package cn.lili.controller.wechat;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.payment.entity.dos.OutOrderLog;
import cn.lili.modules.payment.entity.dto.OutOrderLogSearchParams;
import cn.lili.modules.payment.entity.vo.OutOrderDetailVO;
import cn.lili.modules.payment.service.OutOrderDetailLogService;
import cn.lili.modules.payment.service.OutOrderLogService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分账记录
 *
 * @author Bulbasaur
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "管理端,分账记录接口")
@RequestMapping("/payment/outOrderLog")
public class OutOrderLogController {


    private final OutOrderLogService outOrderLogService;

    private final OutOrderDetailLogService outOrderDetailLogService;


    @ApiOperation(value = "获取分账记录分页")
    @GetMapping
    public ResultMessage<IPage<OutOrderLog>> getByPage(OutOrderLogSearchParams outOrderLogSearchParams) {
        return ResultUtil.data(outOrderLogService.outOrderLogPage(outOrderLogSearchParams));
    }

    @ApiOperation(value = "通过分账单号获取分账信息")
    @GetMapping(value = "/get/{outOrderNo}")
    public ResultMessage<OutOrderLog> get(@PathVariable String outOrderNo) {
        return ResultUtil.data(outOrderLogService.geOutOrderLogByOutOrderNo(outOrderNo));
    }

    @ApiOperation(value = "通过分账单号获取分账明细-具体流水信息")
    @GetMapping(value = "/getDetailLog/{outOrderNo}")
    public ResultMessage<OutOrderDetailVO> getDetailLog(@PathVariable String outOrderNo) {
        return ResultUtil.data(outOrderLogService.getDetailVO(outOrderNo));
    }
}
